<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * 文本框控件FDButton,继承自&lt;a href="FDFieldComponent.html">FDFieldComponent&lt;/a>&lt;br>
<span class='line'>  3</span>  * @example 示例:&lt;br>
<span class='line'>  4</span>  * &lt;pre>&lt;code>
<span class='line'>  5</span> var btn1;
<span class='line'>  6</span> 
<span class='line'>  7</span> window.onload = function() {
<span class='line'>  8</span> 	btn1 = new FDButton({domId:'btn1',text:'按钮文本',onclick:function(){
<span class='line'>  9</span> 		alert(1)
<span class='line'> 10</span> 	}});
<span class='line'> 11</span> }
<span class='line'> 12</span> 
<span class='line'> 13</span> function setOnclickEvent() {
<span class='line'> 14</span> 	btn1.setOnclick(function(){
<span class='line'> 15</span> 		alert(2);
<span class='line'> 16</span> 	})
<span class='line'> 17</span> }
<span class='line'> 18</span> function setText() {
<span class='line'> 19</span> 	btn1.setText('按钮aaa')
<span class='line'> 20</span> }&lt;/code>&lt;/pre>
<span class='line'> 21</span> * @param options 参见&lt;a href="#getOptions">getOptions()&lt;/a>&lt;br>
<span class='line'> 22</span> * @constructor
<span class='line'> 23</span>  */</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">FDButton</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">	</span><span class="NAME">FDButton.superclass.constructor.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">	</span><span class="NAME">this.options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FDLib.util.apply</span><span class="PUNC">(</span><span class="NAME">this.getOptions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">	</span><span class="NAME">this.setOnclick</span><span class="PUNC">(</span><span class="NAME">this.options.onclick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="WHIT">	</span><span class="NAME">this.setValue</span><span class="PUNC">(</span><span class="NAME">this.options.text</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">	</span><span class="NAME">this._initEvent</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">	</span><span class="NAME">this.enable</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 35</span> 
<span class='line'> 36</span> </span><span class="NAME">FDLib.extend</span><span class="PUNC">(</span><span class="NAME">FDButton</span><span class="PUNC">,</span><span class="NAME">FDFieldComponent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 37</span> 
<span class='line'> 38</span> </span><span class="COMM">/**
<span class='line'> 39</span>  * 返回默认属性
<span class='line'> 40</span>  * @return &lt;pre>&lt;code>
<span class='line'> 41</span> {
<span class='line'> 42</span> 	// 按钮文本
<span class='line'> 43</span> 	text:''
<span class='line'> 44</span> 	// 事件函数
<span class='line'> 45</span> 	,onclick:null
<span class='line'> 46</span> }&lt;/code>&lt;/pre>
<span class='line'> 47</span>  */</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="NAME">FDButton.prototype.getOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FDButton.superclass.getOptions.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">FDLib.util.apply</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">,</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">		</span><span class="NAME">text</span><span class="PUNC">:</span><span class="STRN">''</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">		</span><span class="PUNC">,</span><span class="NAME">onclick</span><span class="PUNC">:</span><span class="KEYW">null</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 55</span> 
<span class='line'> 56</span> </span><span class="COMM">/**
<span class='line'> 57</span>  * 设置onclick事件
<span class='line'> 58</span>  * @param onclick 事件函数
<span class='line'> 59</span>  */</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="NAME">FDButton.prototype.setOnclick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">onclick</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">	</span><span class="NAME">this.removeEvent</span><span class="PUNC">(</span><span class="STRN">'click'</span><span class="PUNC">,</span><span class="NAME">this.options.onclick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">	</span><span class="NAME">this.addEvent</span><span class="PUNC">(</span><span class="STRN">'click'</span><span class="PUNC">,</span><span class="NAME">onclick</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">	</span><span class="NAME">this.options.onclick</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">onclick</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 65</span> 
<span class='line'> 66</span> </span><span class="COMM">/**
<span class='line'> 67</span>  * 设置按钮文本
<span class='line'> 68</span>  * @param text 按钮文本
<span class='line'> 69</span>  */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="NAME">FDButton.prototype.setText</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">	</span><span class="NAME">this.setValue</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 73</span> 
<span class='line'> 74</span> </span><span class="COMM">/**
<span class='line'> 75</span>  * 禁用控件
<span class='line'> 76</span>  */</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="COMM">// @override</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="NAME">FDButton.prototype.enable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">	</span><span class="NAME">FDButton.superclass.enable.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">	</span><span class="NAME">this.setStyle</span><span class="PUNC">(</span><span class="STRN">'fdbutton fdbutton-enable'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 82</span> 
<span class='line'> 83</span> </span><span class="COMM">/**
<span class='line'> 84</span>  * 启用控件
<span class='line'> 85</span>  */</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="COMM">// @override</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="NAME">FDButton.prototype.disable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">	</span><span class="NAME">FDButton.superclass.disable.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">	</span><span class="NAME">this.setStyle</span><span class="PUNC">(</span><span class="STRN">'fdbutton fdbutton-disable'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 91</span> 
<span class='line'> 92</span> </span><span class="COMM">/**
<span class='line'> 93</span>  * @private
<span class='line'> 94</span>  */</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="COMM">//@override</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="NAME">FDButton.prototype.getControlHtml</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'&lt;input type="button" />'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 99</span> 
<span class='line'>100</span> </span><span class="NAME">FDButton.prototype._initEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">	</span><span class="NAME">this.addEvent</span><span class="PUNC">(</span><span class="STRN">'mouseover'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">		</span><span class="NAME">self.setStyle</span><span class="PUNC">(</span><span class="STRN">'fdbutton fdbutton-hover'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">	</span><span class="NAME">this.addEvent</span><span class="PUNC">(</span><span class="STRN">'mouseout'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">		</span><span class="NAME">self.setStyle</span><span class="PUNC">(</span><span class="STRN">'fdbutton fdbutton-enable'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>110</span> </span></pre></body></html>